import {Body, Controller, Get, Logger, Post} from '@nestjs/common';
import {CatsService} from "./cats.service";
import {CreateCatsDto} from "./dto/create-cats.dto";

@Controller('cats')
export class CatsController {

    // 创建一个命名的日志器
    private logger = new Logger(CatsController.name);

    // 类似 Spring 中的 @AutoWire
    constructor(private readonly catsService: CatsService) {
    }

    @Post()
    create(@Body() createCatsDto: CreateCatsDto) {
        this.logger.log("创建一个喵咪 ", createCatsDto);
        return this.catsService.create(createCatsDto);
    }

    @Get()
    find() {
        this.logger.debug("查询所有猫咪");
        return this.catsService.find();
    }
}
